# Contributor: Ahmet Ibrahim AKSOY <aaksoy@microsoft.com>
# Maintainer: Microsoft QUIC Team <quicdev@microsoft.com>
pkgname=libmsquic
pkgver=2.4.5
pkgrel=0
_clog=f13417108b0f77260baec4784cf104fb9aff7576
_gtest=ff233bdd4cac0a0bf6e5cd45bda3406814cb2796
_openssl3=330feef3dcb69d95cd752d54cb9254b366bdc7cf
pkgdesc="Cross-platform, C implementation of the IETF QUIC protocol, exposed to C, C++, C# and Rust."
url="https://github.com/microsoft/msquic"
arch="x86_64 armv7 aarch64"
license="MIT"
makedepends="cmake numactl-dev linux-headers lttng-ust-dev openssl-dev perl xz"
checkdepends="perf"
subpackages="$pkgname-dev $pkgname-doc"
source="msquic-$pkgver.tar.gz::https://github.com/microsoft/msquic/archive/refs/tags/v$pkgver.tar.gz
	clog-$_clog.tar.gz::https://github.com/microsoft/CLOG/archive/$_clog.tar.gz
	gtest-$_gtest.tar.gz::https://github.com/google/googletest/archive/$_gtest.tar.gz
	openssl3-$_openssl3.tar.gz::https://github.com/quictls/openssl/archive/$_openssl3.tar.gz
	"
builddir="$srcdir/msquic-$pkgver"

prepare() {
	default_prepare

	cd "$builddir/submodules"
	rm -rf clog googletest openssl openssl3 xdp-for-windows
	mv ../../CLOG-*/ clog/
	mv ../../googletest-*/ googletest/
	mv ../../openssl-*/ openssl3/
}

build() {
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=Release \
		-DQUIC_TLS=openssl3 \
		-DQUIC_ENABLE_LOGGING=true \
		-DQUIC_USE_SYSTEM_LIBCRYPTO=true \
		-DQUIC_BUILD_TOOLS=off \
		-DQUIC_BUILD_TEST=on \
		-DQUIC_BUILD_PERF=off
	cmake --build build
}

check() {
	build/bin/Release/msquictest --gtest_filter=ParameterValidation.ValidateApi
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	rm -rf "$pkgdir"/usr/share/msquic/
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
sha512sums="
51afee7e28a7d6ae1b5491edd635e0c88a92a00bacedeaac632a0f19762e9940c9b819a9d33072d3553c004acd4ec0cdf645301f712b408498053de065b2b1cf  msquic-2.4.5.tar.gz
1eac9dc1227b003f65e736becc90ab455394f2982e6c1802508dfcd2b43bcbe6e718b1e6beaa7f6ffd0e7eb0b6a91ae94802b535388b50d25b1c78d666d7ad8d  clog-f13417108b0f77260baec4784cf104fb9aff7576.tar.gz
056b9503e54b96d5bb424f4088fafa53e416373def7d444b0f7a587b657a9aea9e1d9d74b1f64820d1946fd1ac3fe1654ad70da2649a27f70063352573015c82  gtest-ff233bdd4cac0a0bf6e5cd45bda3406814cb2796.tar.gz
92c144cabc5fbff5f019cdcdad21ed5afebe4ee597ee28140b999b77c8d16d76d33b724104c8b7aa1eb7e7ee0f83b9759a6841477528cec2127e674ac75121dc  openssl3-330feef3dcb69d95cd752d54cb9254b366bdc7cf.tar.gz
"
